var localList=require("../../../utils/localDatas.js");
//index.js
const app = getApp()

Page({
    data: {
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
    },
    onLoad: function () {
        this.setData({
            root: wx.getStorageSync('root'),
            activityList:localList.postData.localList,
            user:localList.postData.userList[wx.getStorageSync('root')],
        })
        console.log(this.data.activityList)
    },
    onShow: function () {
        this.setData({
            root: wx.getStorageSync('root'),
            activityList:localList.postData.localList,
            user: localList.postData.userList[wx.getStorageSync('root')],
        })
        this.tabBar();
    },
    tabBar() {
        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
            this.getTabBar().setData({
                selected: 0,
                root: wx.getStorageSync('root'),
            })
        }
    },
    error: function () {
        wx.showToast({
            title: "网络数据访问错误",
            icon: 'loading',
            duration: 1000
        });
    },
    ok: function () {
        wx.showToast({
            title: "加入成功",
            icon: 'success',
            duration: 1000
        });
    },
    laud: function () {
        console.log(this.data.isOn)
        if (this.data.isOn) {
            this.setData({
                isOn: false
            })
        } else {
            this.setData({
                isOn: true
            })
        }
    },
    searchActivity: function (e) {
        console.log(e.detail.value);
        let key = e.detail.value.toLowerCase();
        let list = this.data.activityList;
        for (let i = 0; i < list.length; i++) {
            let a = key;
            let b = list[i].name.toLowerCase();
            if (b.search(a) != -1) {
                list[i].isShow = true
            } else {
                list[i].isShow = false
            }
        }
        this.setData({
            activityList: list
        })
    },
})